<?php
namespace Admin\Model;
use Admin\AppConst\WebConst;

//app用户model
class UserModel extends BaseModel
{
    /**
     * @var UserModel
     */
    private     static $instance;
    protected   $tableName  = 'user';
    private     $model;
    private     $where;

    //定义所有的表字段
    //定义所有的表字段
    private $id                 = 'id';
    private $lastUpdateTime     = 'last_update_time';
    private $isDelete           = 'is_delete';

    /**
     * Get the instance of UserModel.
     * @return UserModel
     */
    public static function get()
    {
        if (!self::$instance) {
            self::$instance = new UserModel();
        }
        return self::$instance;
    }

    public function __construct(){
        parent::__construct();
        $this->where    = $this->setDefaultWhere(WebConst::DEFAULT_TYPE_FALSE);
        $this->model    = M($this->tableName);
    }

    /**
     * @function    deleteAccount  删除
     * @param       $id         int  id
     * @author      zhangle
     * @date        2018-08-02
     * @return      bool
     */
    public function deleteAccount($id){
        $where  = array(
            $this->id   => $id,
        );
        $save   = array(
            $this->isDelete         => WebConst::DEFAULT_TYPE_DELETE_TRUE,
            $this->lastUpdateTime   => time(),

        );
        //更新
        return $this->model->where($where)->save($save);
    }


    /**
     * @function    getList     获取所有用户
     * @author      zhangle
     * @date        2018-08-02
     * @return      array
     */
    public function getList(){
        return $this->model->select();
    }
    
}